home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
sdf21.zip
/
SDF.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-10-06
|
25KB
|
1,023 lines
Title 'SDF : Speedy Disk Formatter'
; **************************************************************************
; * THIS PROGRAM IS PUBLIC DOMAIN. You Are Free To Use It And Redistribute *
; * It, As Long As No Profit Is Made Out Of It. Redistribution Costs May *
; * Not Exceed $5. This Notice May Not Be Removed Or Altered In Any Way. *
; * Use At Your Own Risk. Author Will Not Be Held Responsible For Any Dama-*
; * ge That Might Result Of Use Or Misuse. Enjoy. *
; **************************************************************************
; This program is inspired from QDR by Vernon D. Buerg, which unfortunately
; has a bug in handling 3.5" floppies.
; Better late than never, I dedicate this program to Ward Christensen, who
; showed us the way in the good old CP/M days ...
; Jacques Pierson, Belgrade (Belgium), November 1987.
; CIS 76446,1516
; Modification history:
; September 1990: fixed bug with DMA boundary errors, and added code to turn
; off the drive motor quickly.
; October 1990: fixed bug in above bug fix.
M24 = 0 ;set to one at work, for an Olivetti M24 (ATT 6300)
bell equ 7
bs equ 8
lf equ 0Ah
cr equ 0Dh
escape equ 1Bh
ulc equ 0C9h ;graphic char - Upper Left Corner
llc equ 0C8h ;Lower Left Corner
urc equ 0BBh ;Upper Right Corner
lrc equ 0BCh ;Lower Right Corner
vb equ 0BAh ;Vertical Border
hb equ 0CDh ;Horizontal Border
;
hsr equ 0EFh ;Head Step Rate : 4 ms
hst equ 0 ;Head Settle Time : 0 ms
;
SDF segment
assume ds:SDF, ss:SDF ,cs:SDF ,es:SDF
org 0100h ;make this a COM file
start: jmp GetCmdLine
; First describe our Disk Base Parms. We will make INT 1Eh to point here
; while formatting. Put at head of program so people without an assembler
; can easily patch this area w/ DEBUG.
OurDBP equ $
db hsr ;high nibble : heads step rate
;low nibble, head unload time
db 2 ;DMA mode
db 255 ;clock ticks before stopping drive motor
db 2 ;sector size - 2 => 512 bytes
db 9 ;How many sectors per track
db 42 ;Gap length between sectors for R/W ops
db -1 ;data length - Not used
db 80 ;Gap length when formatting
db 0F6h ;Formatting char. Dos likes F6's
db hst ;Head settle time in ms.
db 1 ;Motor speed up time in 1/4 sec.
Welcome db cr,lf,'Speedy Disk Formatter, V1.0, '
db '(c) Jacques Pierson, Nov 1987$'
UsageMessage equ $
db cr,lf,lf,'Usage: SDF drv: [switches]',cr,lf
db 'drv: mandatory and is either A: or B:,',cr,lf
db 'No switch => format standard 360K diskette, no verify',cr,lf
db '/Q => format Quad density (3',0abh,'" 720K disk)',cr,lf
db '/V => force Verify after format',cr,lf
db 'Multiple switches may be combined, e.g. SDF b:/q/v.'
db cr,lf,lf,'$'
DriveMissing db cr,lf,lf,'Invalid or missing Drive Spec !$'
WrongSwitch db cr,lf,lf,'Unknown /switch in command line !$'
InsertDisk db cr,lf,lf,'Insert diskette in drive '
Drive db 'A, and press ENTER when ready ...$'
Again db cr,lf,lf,'Format complete,'
Clusters db ' K available to user.'
db cr,lf,'Press ENTER to format another diskette, '
db 'or ESCape to quit...$'
Formatting db cr,lf,lf,'Formatting '
DiskType db 'DSDD, Without$'
Verify db ' Verify.',cr,lf,'$'
Track db cr,'Track: '
TrackNr db ' Side: '
SideNr db ' $'
ShowRetry db bs,'R$'
WritingBoot db ' - writing BOOT$'
WritingFAT db ', FATs$'
WritingDIR db ', DIR.$'
ErrorTbl db 1,'Invalid command '
db 2,'Address mark not found. '
db 4,'Requested sector not found. '
db 8,'DMA overrun on operation. '
db 10h,'Bad CRC on diskette read/write.'
db 20h,'Controller failure. '
db 40h,'SEEK operation failed. '
EndOfErrTbl equ $
FatalErr db bell,cr,lf,lf,'Door Open, Write-protected disk,'
db ' or Drive Fails to respond.'
db cr,lf,'Please fix problem and hit Enter to continue,'
db 'or ESCape to abort...$'
BadClusters db cr,lf,lf,'Bad sectors :'
BadClNr db ' Cluster(s) disabled.',cr,lf,lf,'$'
;
ErrBadSec db bs,bs,', Sec: '
ErrSec db ' , Error '
ErrCode db ' hex : '
ErrMsg db 'Unknown error. ',cr,lf,'$'
;
;
; Flags, set according to switches
;
OptionsFlag db 0 ;default is No Verify, Normal Disk
CtrlBreak db 0 ;Ctrl-Break flag on entry
;
; Disk characteristics, other parms are found in BootSector
;
DirSecs dw 7 ;DIRectory size in sectors
DskTrks db 40 ;Cyls/disk
CurTrk db -1 ;Current track
CurDrv db 0 ;Current drive, binary, BIOS way (A:=0,..)
NeedSetup db 1 ;nonzero if default parms are in effect
even ;Align for those w/8086 processors
RetryCount dw 0 ;Count of retries
MaxTries dw 2 ;Maximum retries attempted
BadSecCnt dw 0 ;Count of Bad Sectors
NextSec dw 0 ;Temp storage for next sector #
INT1Eoff dw 0 ;INT 1Eh offset
INT1Eseg dw 0 ;INT 1Eh segment
INT24off dw 0 ;Critical error handler offset
INT24seg dw 0 ;Critical error segment
;
HexTbl db '0123456789abcdef'
;
ID_tbl dw Side0 ;addr of table of ID's for track 0, side 0
Side0 db 0,0,1,2
db 0,0,2,2
db 0,0,3,2
db 0,0,4,2
db 0,0,5,2
db 0,0,6,2
db 0,0,7,2
db 0,0,8,2
db 0,0,9,2 ;end of side 0
db 0,1,1,2 ;side 1 now
db 0,1,2,2
db 0,1,3,2
db 0,1,4,2
db 0,1,5,2
db 0,1,6,2
db 0,1,7,2
db 0,1,8,2
db 0,1,9,2 ;end of track, side 1
SideLen equ 36
;
;
; Anatomy of our Boot sector
;
BootSector equ $
jmp BootMsg
db 'SDF v01' ;OEM name, 8 chars
dw 512 ;Sector size
db 2 ;Cluster size in sectors
dw 1 ;Reserved sectors
db 2 ;Number of FATs
DirSize dw 112 ;Directory entries
TotSecs dw 720 ;Total sectors
MediaDes db 0FDh ;Media descriptor
FatSize dw 2 ;FAT size in sectors
dw 9 ;Sectors per Track
dw 2 ;Number of heads
dw 0 ;Number of hidden sectors
db 0 ;filler
db 0 ;head
db 10 ;length of BIOS file
db hsr ;The DPB, remember ?
db 2
db 25h
db 2
db 9
db 42
db -1
db 80
db 0F6h
db hst
db 1
NoBootMsg equ $
db cr,lf,lf
db ulc,50 DUP (hb),urc,cr,lf
db vb,' This diskette has been formatted by SDF and ',vb,cr,lf
db vb,' contains no system to boot from. Either ',vb,cr,lf
db vb,' remove it and hit a key to boot from hard disk ',vb,cr,lf
db vb,' if any, or replace it with another disk with a ',vb,cr,lf
db vb,' system to boot from and hit a key when ready. ',vb,cr,lf
db llc,50 DUP (hb),lrc,cr,lf,lf,0
BootMsg:
cli ;no interrupts
cld ;forward direction
mov AX,07C0h ;Boot runtime address
mov DS,AX ;to DS
mov ES,AX
mov SS,AX
mov SP,0 ;temp stack at top of segment
mov SI,(OFFSET NoBootMsg - OFFSET BootSector) ;Msg ptr
BNextChar:
lodsb ;Get byte fm msg
or AL,AL ;a null ?
je ReBoot ;yes, print msg done
mov AH,0Eh ;print char, no bells and whistles
int 10h ;Bios output char INT
jmp SHORT BNextchar ;loop for all string
;
ReBoot: xor AH,AH ;wait for key hit
int 16h
int 19h ;and try booting again
BEndOfStuff equ $
db (510 - (BEndOfStuff - BootSector)) DUP (0) ;filler
db 55h,0AAh ;DOS disk signature
;
; End of boot sector
;
;
; First sector of File Allocation Table
;
FatSec1 equ $
db 0FDh ;FAT - Media descriptor
db 0FFh
db 0FFh
db 509 DUP (0) ;to get a full sector
FatSec2 db 512 DUP (0) ;FAT, second sector
db 512 DUP (0) ;FAT, third sector
;
DirSec1 equ $
DskLbl db 'SDF--------' ;Dir entry for disk label, 11 char
db 28h ;Attributes : Label + Archive
db 10 DUP (0)
TimeLo db 0
TimeHi db 0
Date dw 0
db 486 DUP (0) ;full sector
;
DirSec2 db 512 DUP (0) ;2nd and other sectors
;
;
; Control-Break handler : DO NOT give user a chance to exit w/^C or Break
; without resetting the environement...
;
ControlBreak:
iret ;trap ^C and simply return
;
;
; Critical Error handler: Same as above. Note that, contrary to documentation
; (under DOS 2.1 at least), selecting 'a' under Abort/Retry/Fail does not put
; you into INT 23.
;
CritError:
push AX
push DX
push DS
push CS
pop DS
call Restore
pop DS
pop DX
pop AX
jmp far cs:[IN